# 遍历列表并打印元素
fruits = ["apple", "banana", "cherry"]
index = 0

while index < len(fruits):
    print(fruits[index])
    index += 1
# 输出：
# apple
# banana
# cherry

# 计算列表元素总和
numbers = [1, 3, 5, 7, 9]
total = 0
index = 0

while index < len(numbers):
    total += numbers[index]
    index += 1

print(f"总和：{total}")  # 输出：25

# 结合条件判断
ages = [20, 15, 25, 18, 30]
index = 0

while index < len(ages):
    if ages[index] < 18:
        print(f"{ages[index]} 岁：未成年")
    else:
        print(f"{ages[index]} 岁：成年人")
    index += 1
